package com.foreknow.demo6;

/**
 * 创建一个类(Point),包含两个成员(属性) x,y 分别表示x坐标 y坐标,根据这两个属性生成相应的get/set方法，
 * 创建一个方法movePoint(int dx,int dy)用于实现点的位置移动。创建两个对象p1,p2,然后调用movePoint方法。打印p1和p2的坐标
 */
public class Point {
    private int x;
    private int y;

    public Point(int x,int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void movePoint(int dx,int dy){
        this.x += dx;
        this.y += dy;
    }

    public static void main(String[] args) {
        Point p1 = new Point(2,2);
//        p1.setX(2);
//        p1.setY(2);
        p1.movePoint(6,7);
        System.out.println("p1当前的x坐标："+p1.getX()+" p1当前的y坐标："+p1.getY());
        Point p2 = new Point(3,3);
//        p2.setX(3);
//        p2.setY(3);
        p2.movePoint(5,5);
        System.out.println("p2当前的x坐标："+p2.getX()+" p2当前的y坐标："+p2.getY());
    }
}
